package hk.ust.android_competition.data_reload_tools;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import hk.ust.android_competition.e_pet.R;

/**
 * Created by Silver on 12/1/15.
 */
public class DefaultListViewAdapter extends ArrayAdapter<String> {
    private Context context;
    private int images[];
    private String text[];

    public DefaultListViewAdapter(Context c, String[] foodStrings, int[] images) {
        super(c, R.layout.default_list_element, R.id.content, foodStrings);
        this.context = c;
        this.text = foodStrings;
        this.images = images;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row = inflater.inflate(R.layout.default_list_element, parent, false);

        ImageView img = (ImageView) row.findViewById(R.id.iv_list_view_item_icon);
        TextView storeItem = (TextView) row.findViewById(R.id.content);

        img.setImageResource(images[position]);
        storeItem.setText(text[position]);

        return row;
    }
}

